﻿namespace CardPlay.Model.CardModel
{
    public delegate bool SuitSequenceSpecification(Suit suit, Suit nextSuit);
    public delegate bool RankSequenceSpecification(Rank rank, Rank nextRank);

    public class CardFaceSequenceSpecification
    {
        public SuitSequenceSpecification SuitsInOrder = SuitSequence.DontCare;
        public RankSequenceSpecification RanksInOrder = RankSequence.DontCare;

        public CardFaceSequenceSpecification(
            SuitSequenceSpecification suitSpecification = null, 
            RankSequenceSpecification rankSpecification = null)
        {
            SuitsInOrder = suitSpecification ?? SuitSequence.DontCare;
            RanksInOrder = rankSpecification ?? RankSequence.DontCare;
        }
    
        public bool IsSatisfiedBy(CardFace card, CardFace nextCard)
        {
            return 
                SuitsInOrder(card.Suit, nextCard.Suit) &&
                RanksInOrder(card.Rank, nextCard.Rank);
        }
    }
}
